#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int DaysOfMonth(int year, int month)
{
	switch (month)
	{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		return 31;
		break;
	case 2:
		return 28 + (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);
		break;
	default://4 6 9 11
		return 30;
		break;
	}
}

int main()
{
	int year, month, day;
	while (scanf("%d%d%d", &year, &month, &day) != EOF)
	{
		int days = 0;
		for (int i = 1; i < month; i++)
		{
			days += DaysOfMonth(year, i);
		}
		printf("%d\n", days += day);
	}

	return 0;
}

